package com.hhit.bigscreenbackmanage.controller.jsgl;

import com.alibaba.fastjson.JSONObject;
import com.hhit.bigscreenbackmanage.common.Response;
import com.hhit.bigscreenbackmanage.entity.jsgl.TJsglCspsxm;
import com.hhit.bigscreenbackmanage.entity.jsgl.TJsglTysjBdz;
import com.hhit.bigscreenbackmanage.service.jsgl.TJsglTysjBdzService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/jsgl/tysjBdz")
public class TysjBdzController {

    private Logger log = LoggerFactory.getLogger(TysjBdzController.class);

    @Autowired
    TJsglTysjBdzService tJsglTysjBdzService;

    /**
     * 获取变电站通用设计应用率统计 (旧)
     *
     * @return list
     */
    @RequestMapping("/getbdztysjNum")
    public Response getbdztysjNum(@RequestParam JSONObject jsonObject) {
        try {
            Map<String,String> result = tJsglTysjBdzService.getbdztysjNum(jsonObject);
            return Response.createResponseBySuccess("获取变电站通用设计应用率统计成功",result);
        } catch (Exception e) {
            e.printStackTrace();
            return Response.createResponseByError("获取变电站通用设计应用率统计失败");
        }
    }

    /**
     * 查询 变电站通用设计
     * @param jsonObject
     * @return
     */
    @RequestMapping("/getTysjBdzList")
    public Response getTysjBdzList(@RequestBody JSONObject jsonObject){
        try{
            Map<String, Object> result = tJsglTysjBdzService.queryTysjBdzList(jsonObject);
            return Response.createResponseBySuccess("查询变电站通用设计成功",result);
        }catch (Exception e){
            log.error("查询变电站通用设计失败: " + e.getMessage());
            e.printStackTrace();
            return Response.createResponseByError("查询变电站通用设计失败");
        }
    }

    /**
     * 查询 变电站投产情况
     * @param jsonObject
     * @return
     */
    @RequestMapping("/getTcqkBdzList")
    public Response getTcqkBdzList(@RequestBody JSONObject jsonObject){
        try{
            Map<String, Object> result = tJsglTysjBdzService.queryTcqkBdzList(jsonObject);
            return Response.createResponseBySuccess("查询变电站投产情况成功",result);
        }catch (Exception e){
            log.error("查询变电站投产情况失败: " + e.getMessage());
            e.printStackTrace();
            return Response.createResponseByError("查询变电站投产情况失败");
        }
    }

    /**
     * 查询 模块化变电站统计
     * @param jsonObject
     * @return
     */
    @RequestMapping("/getMkhbdzCount")
    public Response getMkhbdzCount(@RequestBody JSONObject jsonObject){
        try{
            Map<String, Object> result = tJsglTysjBdzService.queryMkhbdzCount(jsonObject);
            return Response.createResponseBySuccess("查询模块化变电站统计成功",result);
        }catch (Exception e){
            log.error("查询模块化变电站统计失败: " + e.getMessage());
            e.printStackTrace();
            return Response.createResponseByError("查询模块化变电站统计失败");
        }
    }

    /**
     * 删除 变电站通用设计记录
     * @param jsonObject
     * @return
     */
    @RequestMapping("/deleteTysjBdzRecord")
    public Response deleteTysjBdzRecord(@RequestBody JSONObject jsonObject){
        try{
            tJsglTysjBdzService.deleteTysjBdzRecord(jsonObject);
            return Response.createResponseBySuccess("删除变电站通用设计记录成功");
        }catch (Exception e){
            e.printStackTrace();
            return Response.createResponseByError("删除变电站通用设计记录失败: "+e.getMessage());
        }
    }

    /**
     * 删除 变电站投产情况记录
     * @param jsonObject
     * @return
     */
    @RequestMapping("/deleteTcqkBdzRecord")
    public Response deleteTcqkBdzRecord(@RequestBody JSONObject jsonObject){
        try{
            tJsglTysjBdzService.deleteTcqkBdzRecord(jsonObject);
            return Response.createResponseBySuccess("删除变电站投产情况记录成功");
        }catch (Exception e){
            e.printStackTrace();
            return Response.createResponseByError("删除变电站投产情况记录失败: "+e.getMessage());
        }
    }
}
